<?php

class Studentpayment extends Zend_Db_Table
{
    protected $_name = 'studentpayment';
    
    public function getOne($id)
    {
        $group = $this->fetchRow('id='.$id);
        return $group;
    }
    
    public function getLastPaymant($user_id){
        $select = $this->getAdapter(); 
        $query = 'SELECT studentpayment.pdate
                FROM studentpayment
                WHERE user_id='.(int)$user_id.'
                AND deleted!=1
                ORDER BY pdate DESC
                LIMIT 1';
         //echo $query; exit();
         $prepare = $select->query($query);
         $result = $prepare->fetchAll(Zend_Db::FETCH_OBJ);
         if(count($result)>0) return $result[0]->pdate;
         else return 'Не найдено';
    }
}
